package com.example.service.implService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.dao.UserDao;
import com.example.pojo.Menu;
import com.example.pojo.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    private final UserDao userDao;
    @Autowired
    public UserServiceImpl(UserDao userDAO) {
        this.userDao = userDAO;
    }

    @Override
    public List<User> getAllUsers() {
        return userDao.getAllUsers();
    }

    @Override
    public IPage<User> getUserByname(int currentPage, int limit,String username) {
        return userDao.getUserByname(currentPage, limit, username);
    }

    @Override
    public IPage<User> getUsersPage(int currentPage, int limit) {
        return userDao.getUsersPage(currentPage, limit);
    }

    @Override
    public User getUserBynameOne(String username){return userDao.getUserBynameOne(username);}

    @Override
    public boolean login(String uname, String pwd) {
        return userDao.login(uname,pwd);
    }

    @Override
    public int toggleStatus(int uid,int checked){
        return userDao.toggleStatus(uid,checked);
    }

    @Override
    public int addUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public int deleteUser(int uid) {
        return userDao.deleteUser(uid);
    }


    @Override
    public boolean getStateByName(String uname) {
        return userDao.getStateByName(uname);
    }

    @Override
    public List<Menu> getUserHaveMenu(User user) {
        return userDao.getUserHaveMenu(user.getId());
    }

    @Override
    public int batchDeleteUser(List<Integer> ids) {
       return userDao.batchDeleteUser(ids);
    }

    @Override
    public int changeStatus(int uId, int uStatus) {
        return userDao.changeStatus(uId, uStatus);
    }

}
